import time

import cv2

cap = cv2.VideoCapture("video/video1.mp4")

while True:
    start_time = time.time()
    ret, frame = cap.read()
    if not ret:
        break
    cv2.imshow("frame", frame)
    wait_time = int(1000 / 30)  # 1000毫秒 = 1秒
    end_time = time.time()
    print(f"帧花费时间为：{(end_time - start_time)}ms")
    if cv2.waitKey(wait_time) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
